Resolving package versions...
No Changes to `/workspaces/Kalman filtering and smoothing/Project.toml`
No Changes to `/workspaces/Kalman filtering and smoothing/Manifest.toml`
Pkg.status()
Status `/workspaces/Kalman filtering and smoothing/Project.toml`
[6e4b80f9] BenchmarkTools v1.8.0
⌃ [31c24e10] Distributions v0.25.131
[b964fa9f] LaTeXStrings v1.4.1
[91a5bcdd] Plots v1.41.7
⌅ [86711068] RxInfer v3.10.1
⌃ [860ef19b] StableRNGs v1.0.4
Info Packages marked with ⌃ and ⌅ have new versions available. Those with ⌃ may be upgradable, but those with ⌅ are restricted by compatibility constraints from upgrading. To see why use `status --outdated`
Kalman filtering and smoothing (Part 3)
This is an analysis of the RxInfer example at https://examples.rxinfer.com/categories/basic_examples/kalman_filtering_and_smoothing/
Some symbols have been changed
Some content has been added/modified
The preference is to make the math and code names align as much as possible
Notation follows FoAI_Notation_Spec.md (v1.23)
Typeface (math)
continuous scalars (this notebook): plain italic, e.g. \(x^{\ast(t)}\), \(y^{(t)}\)
continuous vectors / arrays: italic bold, e.g. \(\boldsymbol{x}\), \(\boldsymbol{\omega}\)
classical / engineering matrices: bold upright sans-serif, e.g. \(\boldsymbol{\mathsf{A}}\), \(\boldsymbol{\mathsf{\Sigma}}\)
tuples (ordered collections that may differ in shape): upright bold, e.g. \(\mathbf{s}\)
Code marks (align with Spec §6)
_ prefix for a bold array/matrix when used; scalars need no _
ː (length mark) suffix for a trajectory, e.g. xˣː, yː
ˣ for a process/environment twin of math $ ^{} $, e.g. xˣ ↔︎ \(x^{\ast}\)
ₜ for the current tick; previous tick ₜ₋₁ (Julia)
Time (math): member index in round-bracket superscripts, e.g. \(x^{\ast(t)}\), \(y^{(t)}\) — not a subscript
Process / environment mark: asterisk before any indices, in one superscript with time, e.g. \(x^{\ast(t)}\) (KaTeX-safe; avoid the broken double-superscript form x^*_{t}^{(t)})
Named channels use subscripts; vector components use square entries \(x^{(t)[n]}\) when a single array is meant
In the following set of examples the goal is to estimate hidden states of a Dynamical process where all hidden states are Gaussians.
We start our journey with a simple
multivariate Linear Gaussian State Space Model (LGSSM), which can be solved analytically. We then solve an
identification problem which does not have an analytical solution. Utimately, we show how RxInfer.jl can
deal with missing observations.
3 Handling Missing Data
An interesting case in filtering and smoothing problems is the processing of missing data. It can happen that sometimes your reading devices fail to acquire the data leading to missing observation.
Let us assume that the following model generates the data
with prior \(x^{(0)} \sim \mathcal{N}(x^{(0)}; m_{x^{(0)}}, v_{x^{(0)}})\). Suppose that our measurement device fails to acquire data from time to time. In this case, instead of scalar observation \(y^{(t)} \in \mathbb{R}\) we sometimes will catch missing observations.
## Data comes from either a simulation/lab (sim|lab) OR from the field (fld)## Data are handled either in batches (batch) OR online as individual points (point)## Batch data accumulates either## along the depth/examples dimension/axis (into the screen/page), OR## typical for supervised & unsupervised learning## along the time dimension/axis (down the screen page)## typical for sequential decision learning (reinforcement learning & active inference)functionsim_batch_data(T; seed=123, μᵥᵥ, σ²ᵥᵥ, μᵥ, σ²ᵥ) ## simulated batch data rng =StableRNG(seed) fEː =fE(T=T) wː =rand(Normal(μᵥᵥ, sqrt(σ²ᵥᵥ)), T) xˣː = fEː + wː gEː =gE(xˣː) vː=rand(Normal(μᵥ, sqrt(σ²ᵥ)), T) yː = gEː + vː y_missingː =similar(yː, Union{Float64, Missing}, )copyto!(y_missingː, yː)for index in missing_indices y_missingː[index] =missingendreturn fEː, xˣː, gEː, yː, y_missingːend